package com.richapp.launcher.database.update.dao;

import android.content.Context;
import android.util.Log;

import com.richapp.launcher.database.update.UpdateBaseDao;
import com.richapp.launcher.database.update.mode.Update;

import java.sql.SQLException;

/**
 * Created by jack on 16/2/25.
 */
public class UpdateDao extends UpdateBaseDao<Update> {


    public UpdateDao(Context context) {
        super(context, Update.class);
    }

    public Update getLast(){
        Update update = null;
        try {
            update = gettOp().queryBuilder().orderBy("updateTime",false).queryForFirst();
        } catch (SQLException e) {
            Log.e(getClass().getName(),"查询数据错误:"+ e== null ? "" : e.getMessage());
        }
        return update;
    }

    public Update getByVersion(String version){
        Update update = null;
        try {
            update = gettOp().queryBuilder().where().eq("version",version).queryForFirst();
        } catch (SQLException e) {
            Log.e(getClass().getName(),"查询数据错误:"+ e== null ? "" : e.getMessage());
        }
        return update;
    }
}
